package com.isaac.sqlSession;

import com.isaac.config.XMLConfigerBuilder;
import com.isaac.pojo.Configuration;
import org.dom4j.DocumentException;

import java.beans.PropertyVetoException;
import java.io.InputStream;

public class SqlSessionFactoryBuilder {

    public SqlSessionFactory build(InputStream inputStream) throws DocumentException, PropertyVetoException, ClassNotFoundException {
        //1. 解析配置文件，封装Configuration
        XMLConfigerBuilder xmlConfigerBuilder = new XMLConfigerBuilder();
        Configuration configuration = xmlConfigerBuilder.parseConfig(inputStream);

        //2. 创建 sqlSessionFactory对象
        DefultSqlSessionFactory defultSqlSessionFactory = new DefultSqlSessionFactory(configuration);
        return defultSqlSessionFactory;
    }
}
